package jzqb.dao.impl;

import cnki.tpi.kbatis.sqlsession.SqlSession;
import cnki.tpi.kbatis.utils.DataSourceUtil;
import jzqb.bo.CollectClassifyBo;
import jzqb.bo.CollectDataBo;
import jzqb.dao.CollectDataDao;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 情报百科数据层实现类
 */
@Repository
public class CollectDataDaoImpl implements CollectDataDao {

    @Override
    public Boolean insertCollectData(CollectDataBo collectDataBo) {
        SqlSession sqlSession = DataSourceUtil.getSqlSession();
        String statementId = "jzqb.dao.CollectDataDao.insertCollectData";
        return sqlSession.executeInsert(statementId, collectDataBo);
    }

    @Override
    public Boolean deleteCollectData(CollectDataBo collectDataBo) {
        SqlSession sqlSession = DataSourceUtil.getSqlSession();
        String statementId = "jzqb.dao.CollectDataDao.deleteCollectData";
        return sqlSession.executeDelete(statementId, collectDataBo);
    }

    @Override
    public CollectDataBo getCollectDataByCondition(CollectDataBo collectDataBo) {
        SqlSession sqlSession = DataSourceUtil.getSqlSession();
        String statementId = "jzqb.dao.CollectDataDao.getCollectDataByCondition";
        return sqlSession.selectOne(statementId, collectDataBo,false);
    }

    @Override
    public List<CollectDataBo> getCollectDataByClassyId(CollectDataBo collectDataBo) {
        SqlSession sqlSession = DataSourceUtil.getSqlSession();
        String statementId = "jzqb.dao.CollectDataDao.getCollectDataByClassyId";
        return sqlSession.selectList(statementId, collectDataBo,false);
    }


    @Override
    public List<CollectDataBo> getAllCollectionData(CollectDataBo collectDataBo) {
        SqlSession sqlSession = DataSourceUtil.getSqlSession();
        String statementId = "jzqb.dao.CollectDataDao.getAllCollectionData";
        return sqlSession.selectList(statementId, collectDataBo,false);
    }

    @Override
    public Long getAllCollectionDataCount(CollectDataBo collectDataBo) {
        SqlSession sqlSession = DataSourceUtil.getSqlSession();
        String statementId = "jzqb.dao.CollectDataDao.getAllCollectionDataCount";
        return sqlSession.getCount(statementId, collectDataBo);
    }

    @Override
    public Boolean updateCollectData(CollectDataBo res) {
        SqlSession sqlSession = DataSourceUtil.getSqlSession();
        String statementId = "jzqb.dao.CollectDataDao.updateCollectData";
        return sqlSession.executeUpdate(statementId, res);
    }

    @Override
    public List<CollectDataBo> getCollectDataSearch(CollectDataBo collectDataBo) {
        SqlSession sqlSession = DataSourceUtil.getSqlSession();
        String statementId = "jzqb.dao.CollectDataDao.getCollectDataSearch";
        return sqlSession.selectList(statementId, collectDataBo,false);
    }

    @Override
    public Long getCollectDataByClassyIdCount(CollectDataBo collectDataBo) {
        SqlSession sqlSession = DataSourceUtil.getSqlSession();
        String statementId = "jzqb.dao.CollectDataDao.getCollectDataByClassyIdCount";
        return sqlSession.getCount(statementId, collectDataBo);
    }

    @Override
    public List<CollectDataBo> getCollectDatasId(CollectClassifyBo collectClassifyBo) {
        SqlSession sqlSession = DataSourceUtil.getSqlSession();
        String statementId = "jzqb.dao.CollectDataDao.getCollectDatasId";
        return sqlSession.selectList(statementId, collectClassifyBo,false);
    }

    @Override
    public Boolean updateCollectDataInfo(CollectDataBo collectDataBo) {
        SqlSession sqlSession = DataSourceUtil.getSqlSession();
        String statementId = "jzqb.dao.CollectDataDao.updateCollectDataInfo";
        return sqlSession.executeUpdate(statementId, collectDataBo);
    }
}
